/**
 * 
 */
package las.dao.util;

import java.io.IOException;
import java.io.Reader;

import las.dao.entity.EventAchievement;
import las.dao.entity.User;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 * @author shayne
 *
 */
public class DBUtil {
	private static SqlSessionFactory sqlSessionFactory;  
    static {  
        try {  

            Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");  
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);  

            reader.close();  
              
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
    
    public static SqlSession getSqlSession(){  
        return sqlSessionFactory.openSession() ;  
    } 
    
//    public static void main(String[] s){
//    	
//    	SqlSession session = DBUtil.getSqlSession();
//    	
//    	EventAchievement ea = (EventAchievement)session.selectOne("findEventAchById", new Integer(1));
//    	System.out.println("Event:" + ea.getEvent().getEventName());
//    	ea.setIsEffect(9);
//    	session.update("updateEventAch", ea);
//    	session.commit();
//    	System.out.println(ea);
//    }
}
